--  Цвета:
--            R         G         B
-- Белый  1111_1111 1111_1111 1111_1111
-- Серый  1100_0000 1100_0000 1100_0000
-- Черный 0000_0000 0000_0000 0000_0000
--
LIBRARY ieee;
USE ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

ENTITY CompImageGenerator IS
	GENERIC(
		pixels_y :	INTEGER := 320;    --row that first color will persist until
		pixels_x	:	INTEGER := 240);   --column that first color will persist until
	PORT(
		disp_ena		:	IN		STD_LOGIC;	--display enable ('1' = display time, '0' = blanking time)
		row			:	IN		std_logic_vector(31 downto 0);		--row pixel coordinate
		column		:	IN		std_logic_vector(31 downto 0);		--column pixel coordinate
		red			:	OUT	STD_LOGIC_VECTOR(7 DOWNTO 0) := (OTHERS => '0');  --red magnitude output to DAC
		green			:	OUT	STD_LOGIC_VECTOR(7 DOWNTO 0) := (OTHERS => '0');  --green magnitude output to DAC
		blue			:	OUT	STD_LOGIC_VECTOR(7 DOWNTO 0) := (OTHERS => '0')); --blue magnitude output to DAC
END CompImageGenerator;

ARCHITECTURE ArchImageGenerator OF CompImageGenerator IS
BEGIN
	PROCESS(disp_ena)
    variable sigRow : integer := 0;
    variable sigColumn : integer := 0;
	BEGIN

		IF(disp_ena = '1') THEN		--display time
 sigRow := conv_integer(row);
 sigColumn := conv_integer(column);

		IF(
			   (sigRow < 640+pixels_y/2) AND (sigColumn < 512+pixels_x/2)
				AND
				(sigRow > 640-pixels_y/2) AND (sigColumn > 512-pixels_x/2)
			   )THEN
				red <= "11000001";--(OTHERS => '1');
				green	<= "11000001";--(OTHERS => '1');
				blue <= "11000001";--(OTHERS => '1');
			ELSE
				red <= "00000001";--(OTHERS => '1');
				green	<= "00000001";--(OTHERS => '1');
				blue <= "00000001";--(OTHERS => '0');
			END IF;
		ELSE								--blanking time
			red <= (OTHERS => '0');
			green <= (OTHERS => '0');
			blue <= (OTHERS => '0');
		END IF;
	
	END PROCESS;
END ArchImageGenerator;